package com.gohome.gohomechat.presenter;

import com.gohome.gohomechat.GoHomeModel;
import com.gohome.gohomechat.model.EditorModel;
import com.gohome.gohomechat.model.entify.CurrentUser;
import com.gohome.gohomechat.model.modellistener.EditorModelInterface;
import com.gohome.gohomechat.presenter.callback.EditorCallBack;
import com.gohome.gohomechat.presenter.presenterlistener.EditorPresenterListener;
import com.gohome.gohomechat.ui.viewlistener.EditorViewInterface;

/**
 * Created by dllo on 16/3/9.
 */
public class EditorPresenter implements EditorPresenterListener {
    private EditorViewInterface editorViewInterface;
    private EditorModelInterface editorModelInterface;

    public EditorPresenter(EditorViewInterface editorViewInterface) {
        this.editorModelInterface = new EditorModel();
        this.editorViewInterface = editorViewInterface;
    }


    @Override
    public void saveData(CurrentUser user) {
        editorViewInterface.showDialog();
        editorModelInterface.save(user, new EditorCallBack() {
            @Override
            public void success() {
                editorViewInterface.saveSuccess();
                editorViewInterface.dismissDialog();
            }

            @Override
            public void failed() {
                editorViewInterface.dismissDialog();
            }
        });
    }
}
